﻿using DataWorks_Sqlite.MappingClass;
using DataWorks_Tools.BasicMethods;
using DataWorks_Tools.CleanDetails;
using DataWorks_Tools.MappModals;
using DataWorks_Tools.MatlabDetails;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DataWorks_Tools.ProcessExcute.MatLabPrediction
{
    public static class MatLabPredictionProcess
    {
        public static async Task<List<string>> DataPredictionProcessExcute(dw_props_admin dw_Props_Admin, dw_props_datapredict dw_Props_Datapredict)
        {
            var selectdatefilearray = dw_Props_Datapredict.selecteddirectory.ReComma().Split(',');
            var originaldatapath = dw_Props_Datapredict.originaldatapath.YXHPathReplace();
            var savedatapath = dw_Props_Datapredict.savedatapath.YXHPathReplace();
            var matfilepath = dw_Props_Datapredict.matfilepath.YXHPathReplace();
            var causalorder = dw_Props_Datapredict.causalorder;
            var uncausalorder = dw_Props_Datapredict.uncausalorder;
            var usefilter=dw_Props_Datapredict.usefilter;
            var lowpass=dw_Props_Datapredict.lowpass;
            var matfilestring = dw_Props_Datapredict.matfilename.ReComma().Split(',');
            var ismultithreads = dw_Props_Admin.ismultithreads;
            var predictthreads = dw_Props_Admin.predictthreadnumber;
            DataPredictModal dataPredictModal = new DataPredictModal();
            dataPredictModal.odpath = originaldatapath;
            dataPredictModal.rdpath = savedatapath;
            dataPredictModal.matfilepath = matfilepath;
            dataPredictModal.datedir = selectdatefilearray;
            dataPredictModal.causalorder = causalorder;
            dataPredictModal.uncausalorder = uncausalorder;
            dataPredictModal.matfilename = matfilestring;
            dataPredictModal.lowpass = lowpass;
            dataPredictModal.usefilter = usefilter;
            dataPredictModal.threads = predictthreads;
            if (originaldatapath != null && savedatapath != null && selectdatefilearray != null && matfilepath != null)
            {
                if (ismultithreads == 1)
                {
                    var t = await ModalPredictionProcess.YXHExcuteDataPredictionMultiThreadLimitedAsync(dataPredictModal);
                    return t;
                }
                else
                {
                    var t = await ModalPredictionProcess.YXHExcuteDataPredictionAsync(dataPredictModal);
                    return t;
                }
            }
            else
            {
                return new List<string>() { "参数错误" };
            }

        }

    }
}
